package org.eclipse.gittab.player;

import java.util.List;

import org.eclipse.gittab.gitTabDsl.Note;
import org.eclipse.gittab.gitTabDsl.Tuning;

/**
 * Player interface for playing sounds created by the {@link GitTabPlayer}.
 * 
 * @author mat
 * 
 */
public interface Player {

	/**
	 * Interface for receiving played notes or unplayed notes.
	 * 
	 * @author mtreitle
	 * 
	 */
	public interface PlayerListener {

		public void noteOn(List<Note> note);

		public void noteOff(List<Note> note);
	}

	public void addPlayerListener(PlayerListener listener);

	public void removePlayerListener(PlayerListener listener);

	/**
	 * Loads the provided tab into the player. Should not be called from the
	 * client.
	 * 
	 * @param tab
	 */
	public void load(ComposedTab tab, Tuning tuning);

	/**
	 * Plays the loaded sequence.
	 */
	public void play();

	/**
	 * Gets the current position in the sequence.
	 * 
	 * @return position expressed in milli-seconds.
	 */
	public long position();

	/**
	 * Gets the length of the sequence.
	 * 
	 * @return length expressed in milli-seconds.
	 */
	public long length();

	/**
	 * Stops playing the sequence.
	 */
	public void stop();

	/**
	 * Unloads the sequence.
	 */
	public void close();

	public void tempo(int bpm);

	public void tempoByFactor(float factor);

	public int getTempo();
}
